import time
from selenium import webdriver
from selenium.webdriver.common.by import By

# 126邮箱登录并发送邮件业务
driver=webdriver.Edge()
driver.maximize_window()
driver.get('https://www.126.com/')
time.sleep(5)
# 进入框架
driver.switch_to.frame(driver.find_element(By.XPATH,'//iframe[starts-with(@id,"x-URS-iframe17")]'))
time.sleep(3)
# 输入用户名
driver.find_element(By.NAME,'email').send_keys('kyt13103053968')
time.sleep(3)
# 输入密码
driver.find_element(By.NAME,'password').send_keys('13103053968123Aa')
time.sleep(8)
# 登录
driver.find_element(By.XPATH,'//*[@id="dologin"]').click()
time.sleep(8)
# 退出框架
driver.switch_to.default_content()
# 发邮件
driver.find_element(By.XPATH,'//*[@id="_mail_component_98_98"]/span[2]').click()
time.sleep(3)
# 收件人
driver.find_element(By.XPATH,'//input[@class="nui-editableAddr-ipt"]').send_keys('2440154941@qq.com')
time.sleep(3)
# 主题   1755435162905_subjectInput
driver.find_element(By.XPATH,'//input[contains(@id,"_subjectInput")]').send_keys('126邮箱发送邮件')
time.sleep(5)
# 发送
driver.find_element(By.XPATH,'/html/body/div[2]/div[1]/div[2]/div[1]/section/footer/div[1]/span[2]').click()
time.sleep(5)